Purpose |
Write data to a device or sequential file. |
||||||||||||||
Syntax |
PRINT # fNum& PRINT # fNum&, [ExpList] [SPC(n)] [TAB(n)] [,] [;] [...] PRINT # fNum&, array$() |
||||||||||||||
Remarks |
The first form of the PRINT# statement (with or without a trailing comma) outputs a blank line to the file (i.e. a CR/LF only). The second form of the PRINT# statement has the following parts, which may occur in any order and quantity, within a single PRINT# statement:
|
||||||||||||||
Restrictions |
Arrays of User-Defined Types (UDTs) may not be used with the array form of the PRINT# statement. |
||||||||||||||
See also |
GET, GET$, GET$$, INPUT#, LINE INPUT#, PUT, PUT$, PUT$$, WRITE# |
||||||||||||||
Example |
' Classic PRINT# statement example SUB MakeFile ' opens a sequential file for output. Using PRINT #, ' it writes lines of different data types to the file. x& = FREEFILE OPEN "INPUT#.DTA" FOR OUTPUT AS #x& StringVariable$ = "I'll be back." IntegerVar% = 1000 FloatingPoint! = 30000.12 ' Write a line of text to the sequential file. PRINT #x&, StringVariable$ PRINT #x&, IntegerVar% PRINT #x&, FloatingPoint! CLOSE #x& ' close file variable END SUB ' end procedure MakeFile
SUB ReadFile ' Opens a sequential file for input. Using INPUT #, ' reads lines of different types of data from the file. x& = FREEFILE OPEN "INPUT#.DTA" FOR INPUT AS #x& RESET StringVariable$ RESET IntegerVar% RESET FloatingPoint! ' Read a line of text from the sequential file. INPUT #x&, StringVariable$ INPUT #x&, IntegerVar% INPUT #x&, FloatingPoint! CLOSE #x& ' close file variable END SUB ' end procedure ReadFile
' Array mode PRINT# statement example a$ = "Trevor, Bob, Bruce, Dave, Simon, Jenny" DIM b$(1 TO PARSECOUNT(a$)) PARSE a$, b$() ARRAY SORT b$() OPEN "filename.txt" FOR OUTPUT AS #1 PRINT #1, b$() CLOSE #1 | ||||||||||||||